<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no" />
    <title>提现账号管理</title>
    <link rel="stylesheet" href="../../css/reset.css">
    <style>
        body {
            width: 100%;
            background-color: #f7f7f7;
            font-size: 0.28rem;
            height: auto;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            font-family: PingFangSC-Regular, sans-serif;
            color: #333333;
            box-sizing: border-box;
        }

        li {
            border-radius: 0.1rem;
            margin-bottom: 0.3rem;
        }

        #wrappernew {
            width: 6.9rem;
            margin-left: calc((100% - 6.9rem) / 2);
        }

        .itemnew {
            width: 100%;
            height: 1.2rem;
            background: #FFFFFF;
            border-radius: 0.1rem;
            overflow: hidden;
        }

        .item-scrollernew {
            width: 120%;
            position: absolute;
            background: #ffffff;
            border-radius: 0.1rem;

        }

        .item-scrollernew>img {
            width: 0.15rem;
            height: 0.3rem;
            position: absolute;
            top: 0.7rem;
            right: 2.2rem;
        }

        .item-scrollernew .txt {
            height: 1.2rem;
            margin-left: 0.2rem;
            font-size: 0.32rem;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            justify-content: center;
            width: 4rem;
            color: rgba(255, 255, 255, 0.8);
        }

        .item-scrollernew .txt span:last-of-type {
            font-size: 0.26rem;
            color: #272727;
        }

        .delnew {
            width: 13%;
            height: 1.2rem;
            position: absolute;
            right: 0;
            top: 0;
            color: #fff;
            text-align: center;
            line-height: 1.2rem;
            z-index: 9999;
        }

        .delnew .shanchu {
            width: 100%;
            height: 1.2rem;
            text-align: center;
            background: red;
            float: left;
            line-height: 1.2rem;
        }

        .addAdressButton {
            border: 1px solid #e2e2e2;
            height: 1.42rem;
            border-radius: 0.1rem;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            font-size: 0.26rem;
        }

        #wrappernew {
            padding-bottom: 0.2rem;
            -webkit-overflow-scrolling: touch;
        }
    </style>
</head>

<body>
    <div class="outAdressList">
        <div id="wrappernew" style="margin-top:0.3rem;">
            <ul id="scrollernew">

            </ul>
        </div>
        <div style="width: 6.9rem;margin-left:calc((100% - 6.9rem)/2)">
            <div class="addAdressButton">
                <span style="font-size: 0.6rem">
                    ＋
                </span>
                <span>
                    添加提币地址
                </span>
            </div>
        </div>
    </div>
    <script src="../../script/autosize.js"></script>
    <script src="../../script/fastclick.js"></script>
    <script src="../../script/jquery_three_two_one.js"></script>
    <script src="../../script/jrollmin.js"></script>
    <script src="../../script/app.js"></script>
    <script>
        function getTimeNow() {
            var now = new Date();
            return now.getTime();
        }
        function touchend() {
            clearInterval(time); //如果按下时间不到1000毫秒便弹起，
        }
        function touchstart() {
            timeStart = getTimeNow(); //获取鼠标按下时的时间
            time = setInterval(function () {
                timeEnd = getTimeNow(); //也就是每100毫秒获取一次时间
                if (timeEnd - timeStart > 700) //如果此时检测到的时间与第一次获取的时间差有1000毫秒
                {
                    clearInterval(time); //便不再继续重复此函数 （clearInterval取消周期性执行）
                }
            }, 100);
        }
    </script>
    <script>
        apiready = function () {
            var app = new APP();
            var account = app.getAccount();
            var coinName = api.pageParam.coinName;
            function jrollnew() {
                // 创建外层jroll实例
                var jroll = new JRoll("#wrappernew", {
                    scrollBarY: false
                });
                var items = document.querySelectorAll(".itemnew");
                var current = null;
                //保存当前滑开的item
                for (var i = 0; i < items.length; i++) {
                    // 每行创建jroll实例
                    var j = new JRoll(items[i], {
                        scrollX: true,
                        bounce: false
                    });
                    j.on("scrollStart", function () {
                        if (current && current !== this) {
                            current.scrollTo(0, 0, 100);
                            current = null;
                        }
                    });
                    j.on("scroll", function (e) {
                        if (this.x === 0 && !current) {
                            this.call(jroll, e);
                        } else {
                            current = this;
                        }
                    });
                    j.on("scrollEnd", function () {
                        if (this.x > -50) {
                            this.scrollTo(0, 0, 100);
                            current = null;
                        } else {
                            this.scrollTo(this.maxScrollX, 0, 100);
                        }
                    })
                };
            }
            function touchend() {
                clearInterval(time); //如果按下时间不到1000毫秒便弹起，
            }
            function touchstart(name) {
                timeStart = getTimeNow(); //获取鼠标按下时的时间
                time = setInterval(function () {
                    timeEnd = getTimeNow(); //也就是每100毫秒获取一次时间
                    if (timeEnd - timeStart > 700) //如果此时检测到的时间与第一次获取的时间差有1000毫秒
                    {
                        clearInterval(time); //便不再继续重复此函数 （clearInterval取消周期性执行）
                    }
                }, 100);
            }
            var deletId = "";//删除地址ID
            //获取地址列表
            function getAdressList() {
                var account = app.getAccount();
                app.ajaxPro({
                    url: "member/get-tb-address",
                    values: {
                        token: account.token,
                        currency_code: coinName
                    },
                    openFlower: true
                }, function (ret) {
                    if (ret.code == 200) {
                        var newarr = ret.data.lists;
                        if (newarr.length > 0) {
                            var teplte = '';
                            for (var i = 0; i < newarr.length; i++) {
                                teplte += '<li class="itemnew" data-id=' + newarr[i].id + 'ontouchend="touchend()" data-address=' + newarr[i].wallet_address + ' ontouchmove="touchend()"ontouchstart="touchstart()"><div class="item-scrollernew"><div class="txt"><p class="adressTtitle"><img src="../../image/icondizhix.png"style="width:0.28rem;margin-right:0.15rem;"><span>' + newarr[i].remark + '</span></p><span style="margin-left: 0.43rem;color:#B2B2B2;">' + newarr[i].wallet_address + '</span></div><div class="delnew"><div class="shanchu" data-name=' + newarr[i].id + '>删除</div></div></div></li>'
                            }
                            $("#scrollernew").append(teplte);
                            if (newarr.length > 6) {
                                $("#wrappernew").css({
                                    height: "8rem",
                                    overflowY: "scroll !important"
                                })
                            }
                            jrollnew();
                        }
                    }
                })
            }
            getAdressList();
            $(".addAdressButton").click(function () {
                var pageValue = {
                    name: "adress_add",
                    subpage: "salescommission/adress_add",
                    title: "添加提币地址",
                    allowEdit: true,
                    param: {
                        pageName: "adress_add",
                        coinName: coinName,
                        allowEdit: true
                    },
                }
                app.setNavBarAttr(pageValue);
            })
            $("#scrollernew").on("click", "li", function () {
                var chooseAddress = $(this).attr("data-address");
                app.trigger("chooseAddress", chooseAddress);
                app.closeW();
            })
            var deletId = "";//删除条目的id
            $("#scrollernew").on("click", "li .shanchu", function (e) {
                e.stopPropagation();
                deletId = $(this).attr("data-name");
                var param = {
                    dtype: "dialog53",
                    data: {
                        title: '提示',
                        text: "确认删除该提币地址？",
                        cancel: 'cancel',
                        confirm: 'confirmDelet',
                        cancentxt: '取消',
                        confirmtxt: '确定',
                        stopPropagation: true,//阻止点击body冒泡
                    }
                };
                //提示公共弹窗
                app.dialog(param);
            })
            app.listen("confirmDelet", function () {
                if (!deletId) return
                app.ajaxPro({
                    url: "member/del-tb-address",
                    values: {
                        token: account.token,
                        id: deletId
                    },
                    openFlower: true
                }, function (ret) {
                    if (ret.code == 200) {
                        app.toast("删除成功");
                        deletId = "";
                        $('#scrollernew').empty();
                        getAdressList();
                    }
                })
            })
            app.listen("addAdrssSu", function () {
                $('#scrollernew').empty();
                getAdressList();
            });
            app.headerMap();
        }
    </script>
</body>

</html>